package org.activequant.data.retrieval.mappings;

import org.activequant.core.domainmodel.InstrumentSpecification;
import org.activequant.core.domainmodel.data.Quote;
import org.activequant.core.mappings.IInstrumentSpecificationMapper;
import org.activequant.core.types.TimeFrame;
import org.activequant.data.retrieval.IQuoteSubscriptionSource;
import org.activequant.data.retrieval.ISubscription;

/**
 * QuoteSubscriptionSourceMappingProxy extends SubscriptionSourceMappingProxy&lt;Quote&gt; implements IQuoteSubscriptionSource.
 * Holds the following associated variable:
 * <ul>
 * <li>source(IQuoteSubscriptionSource)</li>
 * </ul>
 * Inherits the following variables:
 * <ul>
 * <li>subscriptions(List&lt;ISubscription&lt;Quote&gt;&gt;)</li>
 * <li>mapper(IInstrumentSpecificationMapper)</li>
 * </ul>
 * <br>
 * <b>History:</b><br>
 *  - [20.01.2008] Created (Erik Nijkamp)<br>
 *
 *  @author Erik Nijkamp
 */
public class QuoteSubscriptionSourceMappingProxy extends
		SubscriptionSourceMappingProxy<Quote> implements
		IQuoteSubscriptionSource {
	/**
	 * private IQuoteSubscriptionSource source;
	 */
	private IQuoteSubscriptionSource source;
	/**
	 * constructs a QuoteSubscriptionSourceMappingProxy(extends SubscriptionSourceMappingProxy&lt;Quote&gt; implements IQuoteSubscriptionSource) 
	 * using the given source(IQuoteSubscriptionSource) and mapper(IInstrumentSpecificationMapper) to set its associated
	 * source(IQuoteSubscriptionSource) and inherited mapper(IInstrumentSpecificationMapper)
	 * @param source
	 * @param mapper
	 */
	public QuoteSubscriptionSourceMappingProxy(IQuoteSubscriptionSource source, IInstrumentSpecificationMapper mapper) {
		super(mapper);
		this.source = source;
	}
	/**
	 * subscribes and returns an ISubscription&lt;Quote&gt; for the given spec(InstrumentSpecification) and timeFrame(TimeFrame) by using the associated 
	 * source(IQuoteSubscriptionSource)
	 */
	protected ISubscription<Quote> handleSubscribe(InstrumentSpecification spec, TimeFrame timeFrame) throws Exception {
		return source.subscribe(spec);
	}
}
